package com.example.concurrency.publish;

import com.example.concurrency.annotation.NotThreadSafe;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * 对象的发布
 *
 * @author 文希
 * @create 2019-05-16 23:22
 */
@Slf4j
@NotThreadSafe
public class UnsafePublish {

    private String[] states = {"a","b","c"};

    public String[] getStates() {
        return states;
    }

    public static void main(String[] args) {
        UnsafePublish publish = new UnsafePublish();
        log.info("{}", Arrays.toString(publish.getStates())); // [a, b, c]

        publish.getStates()[0] = "d";
        log.info("{}", Arrays.toString(publish.getStates())); // [d, b, c]
    }
}
